{extend name="admin@index_layout"/}
{block name="main"}
<style type="text/css">
    .childrenBody {
        background: #fff;
    }
</style>
<div class="layui-card">
    <div class="layui-card-header">查询管理</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
    </div>
</div>
<script type="text/html" id="picTpl">

    <img style="max-width:80px; max-height:30px;" src="{{d.first_img}}" data-image="{{d.name}}">

</script>
<script type="text/html" id="barTool">

    {{# if(d.is_js==0){ }}
    <a class="layui-btn layui-btn-xs  layui-btn-warm" data-open='{:url("editfee")}?id={{ d.id }}' data-title="评估扣费"
    >评估扣费</a>
    {{# } }}

    {if $userInfo['roleid']==1}
    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="物价评估"
       data-full="true">物价评估</a>
    <a href='{:url("del",["catid"=>$catid])}?ids={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
    {/if}
</script>


<script type="text/html" id="recommendTpl">
    <input type="checkbox" name="recommend" data-href='{:url("recommend")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="推荐|不推荐" lay-filter="switchStatus" {{ d.recommend==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="上架|下架" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

{/block}
{block name="script"}
<script>
    layui.use(['table', 'yznTable'], function () {
        // var table = layui.table,
        //     $ = layui.$,
        //     form = layui.form,
        //     table = layui.table,
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            add_url: "{:url('add',['catid'=>$catid])}",
            delete_url: "{:url('del',['catid'=>$catid])}",
            modify_url: '{:url("listorder",["catid"=>$catid])}',
        };

        table.render({
            init: init,
            id: 'currentTable',
            elem: '#currentTable',
            url: '{:url("index")}',
            // searchFormTpl:,
            toolbar: ['refresh',
                // [{
                //     text: '添加',
                //     url: init.add_url,
                //     method: 'open',
                //     icon: 'iconfont icon-add',
                //     class: 'layui-btn layui-btn-normal layui-btn-sm',
                //     extend: 'data-full="true"',
                // }],
            ],
              cols: [
                [
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'id',align: "center",  width: '5%', title: 'ID'},

                    {field: 'name',align: "center",  width: '15%', title: '单位名称'},


                    {
                        field: 'qw_type', align: "center", width: '8%', title: '期望价格', templet: function (d) {
                            if (d.qw_type == 1) {
                                return '<span style="color: #0000FF">市场价</span>';
                            } else if (d.qw_type == 2) {
                                return '<span style="color: #2A57FE">4s店价</span>';
                            }else{
                                return '<span>未知</span>';
                            }
                        }, selectList: {1:'市场价',2:'4s店价'}
                    },

                    {
                        field: 'is_j', align: "center", width: '8%', title: '是否加急', templet: function (d) {
                            if (d.is_j == 1) {
                                return '<span style="color: green">普通</span>';
                            } else if (d.is_j == 2) {
                                return '<span style="color: red">加急</span>';
                            }else{
                                return '<span>未知</span>';
                            }
                        }, selectList: {1:'普通',2:'加急'}
                    },




                    {
                        field: 'status', align: "center", width: '8%', title: '估价状态', templet: function (d) {
                            if (d.status == 0) {
                                return '<span style="color: red">待估价</span>';
                            } else if (d.status == 1) {
                                return '<span style="color: green">已估价</span>';
                            }else{
                                return '<span>未知</span>';
                            }
                        }, selectList: {0:'待估价',1:'已估价'}
                    },
                    {field: 'status_time',  width: '15%', align: "center", title: '估价时间',search: false},


                    {
                        field: 'is_js', align: "center", width: '8%', title: '是否扣费', templet: function (d) {
                            if (d.is_js == 0) {
                                return '<span style="color: red">未扣费</span>';
                            } else if (d.is_js == 1) {
                                return '<span style="color: green">已扣费</span>';
                            }else{
                                return '<span>未知</span>';
                            }
                        }, selectList: {0:'未扣费',1:'已扣费'}
                    },
                    {field: 'js_money',  width: '8%', align: "center", title: '扣费金额',search: false},

                    {field: 'create_time',  width: '15%', align: "center", title: '申请时间', search: 'range'},

                    {fixed: 'right',  width: '20%',align: "center", title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);
        yznTable.bindevent();
    });
</script>
{/block}